#include"server/server.hpp"

//测试1.发送的数据的长度与实际正文长度不匹配，业务不会处理，超过时长自动释放
// 2.发送多次小请求，服务器会将后面的请求当作第一个请求的正文，这样第一个请求被处理了，处理第二个时就会出错
int main()
{
    Socket client_sock;
    client_sock.CreateClient(8888,"127.0.0.1");
    std::string httprequest;
    httprequest += "GET /hello HTTP/1.1\r\nConnection: keep-alive\r\nContent-Length: 100\r\n\r\nwojiaoliubiyuan";
    while(1)
    {
        assert(client_sock.Send(httprequest.c_str(),httprequest.size()) != -1);
        assert(client_sock.Send(httprequest.c_str(),httprequest.size()) != -1);
        assert(client_sock.Send(httprequest.c_str(),httprequest.size()) != -1);
        char buffer[1024] = {0};
        assert(client_sock.Recv(buffer,1023) != -1);

        DBG_LOG("[%s]",buffer);

        sleep(3);
    }
    return 0;
}

// int main()
// {
//     Socket client_sock;
//     client_sock.CreateClient(8888,"127.0.0.1");
//     std::string httprequest;
//     httprequest += "GET /hello HTTP/1.1\r\nConnection: keep-alive\r\nContent-Length: 100\r\n\r\nwojiaoliubiyuan";
//     while(1)
//     {
//         assert(client_sock.Send(httprequest.c_str(),httprequest.size()) != -1);
//         char buffer[1024] = {0};
//         assert(client_sock.Recv(buffer,1023) != -1);

//         DBG_LOG("[%s]",buffer);

//         sleep(3);
//     }
//     return 0;
// }